#!/usr/bin/perl

# $Id: 11_dbwrapper.t 198 2010-07-11 11:03:13Z dolbanavt $
# $Date: 2010-07-12 21:51:21 +0300 (Пнд, 12 Июл 2010) $
# $HeadURL: https://robosearch.googlecode.com/svn/branches/reborn/t/11_dbwrapper.t $
# $LastChangedRevision$

use FindBin qw( $RealBin );
use File::Spec::Functions qw( catfile );

BEGIN {
    push @INC, catfile( $RealBin, '..', 'base_lib' );
    push @INC, catfile( $RealBin, '..', 'lib' );
}

use JIP::ToolSet;
use English qw( -no_match_vars );
use Test::More tests => 9;
use Const::Fast qw( const );
use Test::Exception;

const my $MODULE => 'DBWrapper';

use_ok $MODULE;
require_ok $MODULE;

can_ok $MODULE, qw(
    new _init
    set_dbh get_dbh
);

throws_ok { $MODULE->new(); }
    qr{^Required\soption\s'dbh'\sis\snot\sprovided}xms,
    'new( dbh )';

my $o = $MODULE->new( dbh => 'preved' );

ok $o, 'got object';

isa_ok $o, $MODULE;
isa_ok $o, 'JIP::BaseClass';
isa_ok $o, 'Class::Accessor::Fast';

is $o->get_dbh, 'preved', 'dbh accessor';
